package pb032.droid.nav;

public class Coordinate {

    private double x;
    private double y;

    public Coordinate() {
	super();
    }

    public Coordinate(double x, double y) {
	this.x = x;
	this.y = y;
    }

    /**
     * Berechnung des Abstandes zweier Koordinaten nach Pythagoras
     * 
     * @param c
     * @return
     */
    public double calculateCoordinateDistance(Coordinate c) {
	/*
	 * d: Abstand der Koordinaten, dX: Differenz x-Koordinaten, dY:
	 * Differenz y-Koordinaten
	 */
	double d, dX, dY;

	if (this.getX() < c.getX()) {
	    dX = c.getX() - this.getX();
	} else {
	    dX = this.getX() - c.getX();
	}

	if (this.getY() < c.getY()) {
	    dY = c.getY() - this.getY();
	} else {
	    dY = this.getY() - c.getY();
	}

	d = Math.sqrt((dX * dX) + (dY * dY));

	return d;
    }

    public void setY(double y) {
	this.y = y;
    }

    public double getY() {
	return y;
    }

    public void setX(double x) {
	this.x = x;
    }

    public double getX() {
	return x;
    }
}